import { defineComponent, reactive, Teleport } from "vue";
import styles from "./Terms.module.less";
import LIcon from "@/components/public/lIcon/lIcon";
export default defineComponent({
  setup(props, { expose }) {
    const state = reactive({
      isShow: false,
      list: [] as any[],
    })
    // 打开弹窗
    const open = (list: any[]) => {
      state.list = list || [];
      state.isShow = true;
    }
    expose({
      open,
    })
    return () => (
      <div class={styles['terms-floating']} v-show={state.isShow}>
        <div class={styles['terms-card']}>
          <div class={styles['card-header']}>
            <span class={styles.title}>保险条款</span>
            <LIcon type="icon-delete-x" class={styles['icon-delete']} onClick={() => { state.isShow = false }} />
          </div>
          <div class={styles['card-container']}>
            <div class={styles.table}>
              <div class={styles['table-header']}>
                <div class={styles['table-col']}>
                  <div class={styles.col}>
                    <div class={styles.cell}>
                      <span>保险条款</span>
                    </div>
                  </div>
                </div>
                <div class={styles['table-col']}>
                  <div class={styles.col}>
                    <div class={styles.cell}>
                      <span>操作</span>
                    </div>
                  </div>
                </div>
              </div>
              <div class={styles['table-rows']}>
                {
                  state.list.map((item: any) => (
                    <div class={styles['table-row']}>
                      <div class={styles['table-col']}>
                        <div class={styles.col}>
                          <div class={styles.cell}>
                            <span>{item.name}</span>
                          </div>
                        </div>
                      </div>
                      <div class={styles['table-col']}>
                        <div class={styles.col}>
                          <div class={styles.cell}>
                            <span class={styles.download} onClick={() => { window.location.href = item.file }}>下载</span>
                          </div>
                        </div>
                      </div>
                    </div>
                  ))
                }
              </div>
            </div>
          </div>
        </div>
      </div>
    )
  }
})